<template>
	<view>
		
		<cu-custom bgColor="bg-gradual-blue">
			<block slot="content">个人中心</block>
		</cu-custom>
		<!-- 加载动画 -->
		<view v-if="pageLoad" class="text-gray padding justify-center flex align-center">
			<u-loading mode="circle" color="#2979ff" size="40"></u-loading>
			<view class="margin-left-sm">加载中...</view>
		</view>
		<view v-if="!pageLoad">
			
			<view class="cu-list menu-avatar">
				<view class="cu-item">
					<view class="cu-avatar round lg" :style="'background-image:url('+ user.avatar +')'" @click="gourl('/pages/user/user_head')"></view>
					<view class="content flex-sub">
						<view>{{user.nickname}}</view>
						<view class="text-gray flex justify-between">
							<view class="text-sm">注册时间：{{user.register_date}}</view>			
							<view> 
								<navigator url="/pages/user/set" class="margin-right-xl block text-black">
									<text class="cuIcon-settingsfill"></text>设置
								</navigator> 
							</view>							
						</view>					
					</view>				
				</view>
			</view>
				
			<view class="cu-list menu sm-border">
				<view class="cu-item arrow" @click="gourl('/pages/user/mypublish/mypublish')">
					<view class="content">
						<text class="cuIcon-form text-blue"></text>
						<text class="">我发布的任务</text>
					</view>
				</view>
				<view class="cu-item arrow" @click="gourl('/pages/user/myaccept')">
					<view class="content">
						<text class="cuIcon-goods text-green"></text>
						<text>我接受的任务</text>
					</view>
				</view>
				<view class="cu-item arrow" @click="gourl('/pages/user/mysend')">
					<view class="content">
						<text class="cuIcon-deliver text-green"></text>
						<text>我寄的快递</text>
					</view>
				</view>
				<button class="cu-item arrow" open-type="contact">
					<view class="button">
						<text class="cuIcon-mark text-green" style="padding-left: 10upx;"></text>
						<text style="padding-left: 20upx;">联系客服</text>
					</view>
				</button>
			</view>

		</view>

	</view>
</template>

<script>
	import mdate from "@/common/date.js"; 
	import { mapGetters } from 'vuex'
	export default {
		computed: {
			...mapGetters(['userInfo'])
		},
		data() {
			return {
				pageLoad: true,
				user: {}
			}
		},
		onLoad: function(option) {
			this.getPage()
		},
		methods: {
			gourl: function(path) {
				uni.navigateTo({
					url: path,
				})
			},
			getPage: function() {
				uniCloud.callFunction({
					name: "user-center",
					data: {
						action: "get",
						id:this.userInfo._id
					},
					success: (e)=>{
						var res = e.result
						if (res.error) {
							return false
						}
						this.pageLoad = false
						this.user = res.data.user
						this.user.register_date=new Date(this.user.register_date).Format("yyyy-MM-dd");	
					}
				})
			}
		},
	}
</script>

<style scoped lang="scss">
	.button{
		font-size: 30rpx;
	}
</style>
